package com.sskj.jgxt.trans;

import com.sskj.jgxt.jd.entity.FoundWT;
import com.sskj.jgxt.jd.entity.JianDuJiLu;
import com.sskj.jgxt.jd.entity.JianDuJiLuCJJG;
import com.sskj.jgxt.jd.entity.JianDuJiLuRenYuan;
import com.sskj.jgxt.jd.entity.WenTiIMG;
import com.sskj.jgxt.jd.entity.WenTiLX;
import com.sskj.jgxt.jd.vo.CJJGVO;
import com.sskj.jgxt.jd.vo.FoundWTVO;
import com.sskj.jgxt.jd.vo.JiLuRenYuanVO;
import com.sskj.jgxt.jd.vo.JianDuCoreVO;
import com.sskj.jgxt.jd.vo.WenTiIMGVO;
import com.sskj.jgxt.jd.vo.WenTiLXVO;

public class BeanTransCore {

	public JianDuCoreVO trans(JianDuCoreVO vo, JianDuJiLu o) {

		// 记录基本信息
		vo.setId(o.getId());
		vo.setCoding(o.getCoding());
		vo.setEngId(o.getEng().getOid());
		vo.setJllx(o.getJllx());
		vo.setJlrq(o.getJlrq());
		vo.setJlr(o.getJlr());
		vo.setTqqk(o.getTqqk());
		vo.setNote(o.getNote());
		vo.setXxjdms(o.getXxjdms());
		vo.setGlJdjlId(o.getGlJdjlId());
		vo.setShzt(o.getShzt());
		vo.setShqfrName(o.getShqfrName());
		vo.setShqfsj(o.getShqfsj());
		vo.setCreateId(o.getCreatorId());
		vo.setJdyj(o.getJdyj());
		if (o.getMap() != null) {
			vo.setLatitude(o.getMap().getLatitude());
			vo.setLongitude(o.getMap().getLongitude());
			vo.setTitle(o.getMap().getTitle());
		}
		transJdy(o, vo);
		transMap(o, vo);
		transCjjg(o, vo);
		transFoundWT(o, vo);
		transImg(o, vo);
		return vo;
	}

	// 转换图片
	public void transImg(JianDuJiLu o, JianDuCoreVO vo) {
		for (WenTiIMG img : o.getImages()) {
			WenTiIMGVO imgvo = new WenTiIMGVO(img.getId(), img.getImgUrl());
			vo.getImgs().add(imgvo);
		}
	}

	// 转换监督人员
	public void transJdy(JianDuJiLu o, JianDuCoreVO vo) {

		for (JianDuJiLuRenYuan jdy : o.getJdrys()) {
			JiLuRenYuanVO ryvo = new JiLuRenYuanVO(jdy.getName(), jdy.getUserId());
			vo.getRys().add(ryvo);
		}
	}

	// 转换地图
	public void transMap(JianDuJiLu o, JianDuCoreVO vo) {
		if (null != o.getMap())
		{
			vo.setLatitude(o.getMap().getLatitude());
			vo.setLongitude(o.getMap().getLongitude());
			vo.setTitle(o.getMap().getTitle());
		}	
	}

	// 转换问题
	public void transFoundWT(JianDuJiLu o, JianDuCoreVO vo) {
		for (FoundWT wt : o.getWt()) {
			FoundWTVO wtvo = new FoundWTVO(wt.getWt(), wt.getLxms(), wt.getWtms(), wt.getSort());
			transWtlx(wt, wtvo);
			transWtimg(wt, wtvo);
			vo.getWts().add(wtvo);
		}
	}

	// 转换问题图片
	public void transWtimg(FoundWT o, FoundWTVO vo) {
		for (WenTiIMG img : o.getImages()) {
			WenTiIMGVO imgvo = new WenTiIMGVO(img.getId(), img.getImgUrl());
			vo.getWtimgs().add(imgvo);
		}
	}

	// 转换问题类型
	public void transWtlx(FoundWT o, FoundWTVO vo) {
		for (WenTiLX wtlx : o.getWtlx()) {
			WenTiLXVO wtlxvo = new WenTiLXVO(wtlx.getText(), wtlx.getChecked());
			vo.getWtlx().add(wtlxvo);
		}
	}

	// 转换记录机构信息
	public void transCjjg(JianDuJiLu o, JianDuCoreVO vo) {
		for (JianDuJiLuCJJG cjjg : o.getCjjgs()) {
			CJJGVO cjjgvo = new CJJGVO(cjjg.getJglx(), cjjg.getOrgName(), cjjg.getEngOrgId(), cjjg.getChecked(),
					cjjg.getSort());
			vo.getCjjgs().add(cjjgvo);
		}
	}

}
